1190 OPTION BASE 1:DEFINT A-Z:CR$="}":DQ$=CHR$(34)
1200 BL=190
1210 WIDTH 80:KEY OFF:CLS
1220 ON ERROR GOTO 1360
1230 FOR I= 1 TO 10:KEY I,"":NEXT I
1240 DIM A$(101) 'Name of redefined key (one more element for scratch)
1250 DIM B$(100) 'string assigned to key
1260 DIM C$(100) 'string saved to DOS file
1265 DIM D$(32) 'code key names for ascii values 1-32
1270 DIM E$(140) 'Extended code key names
1275 DIM L(100) 'length of (extended) key
1280 GOSUB 2300 'Opening screen
1290 GOSUB 1940 'Load ascii and extended codes into D$ and E$ array
1300 GOSUB 1420 'Ask filename & process file contents
1310 GOSUB 1510 'Print existing definitions to screen
1320 '& solicit key to be redefined or stop
1330 GOSUB 2150 'save key redefinitions (or cancel) and quit
1340 LOCATE 25,1:PRINT "Choose from: E)dit same again / R)ead (new) file / Q)uit to DOS / B)asic prompt";
1342 I$=INKEY$:WHILE I$="":WHILE I$="":I$=INKEY$:WEND:IF INSTR("EeRrQqBb",I$)=0 THEN BEEP:I$="":WEND
1344 IF INSTR("Ee",I$)<>0 THEN 1310
1346 IF INSTR("Rr",I$)<>0 THEN 1300
1347 IF INSTR("Qq",I$)<>0 THEN ON ERROR GOTO 0:SYSTEM
1348 IF INSTR("Bb",I$)<>0 THEN CLS:LOCATE 25,1:PRINT "Type 'CONT <CR>' to resume with last redefinitions";:LOCATE 1,1:ON ERROR GOTO 0:END:ON ERROR GOTO 1360:GOTO 1310 'to continue anyway
1349 STOP 'this statement may never be executed, if so: an error in programming
1350 '
1360 ' error handling subroutine
1370 '
1380 IF ERL=1460 AND ERR=53 THEN RESUME 1490
1400 CLS:PRINT "Error code ";ERR;" in line #",ERL:END
1410 '
1420 ' open key file to hold definitions
1430 '
1440 CLS:LOCATE 13,1
1450 PRINT "Enter name of file for Keyboard Reassignments [C:\DOSKEYRE.DEF]: ":
1455 INPUT "",F$:IF F$="" THEN F$="C:\DOSKEYRE.DEF"
1460 N=0:OPEN "i",#1,F$
1470 WHILE NOT EOF(1) AND N<100:N=N+1:LINE INPUT #1,C$(N):GOSUB 1820:WEND
1480 NK=N:CLOSE '====== a maximum of 100 lines (definitions) read
1770 C$(N)=B$(N):N$=DQ$+"p":IF RIGHT$(C$(N),1)=CR$ THEN C$(N)=MID$(C$(N),1,LEN(C$(N))-1):N$=DQ$+";13p" '=== convert trailing CR in definition
1771 I=1
1772 J=INSTR(I,C$(N),DQ$):IF J<>0 THEN C$(N)=MID$(C$(N),1,J-1)+DQ$+";34;"+DQ$+MID$(C$(N),J+1):I=J+6:GOTO 1772 '=== convert embedded DQ's in definition
1774 I=1
1775 J=INSTR(I,C$(N),CR$):IF J<>0 THEN C$(N)=MID$(C$(N),1,J-1)+DQ$+";13;"+DQ$+MID$(C$(N),J+1):I=J+6:GOTO 1775 '=== convert embedded CR's in definition
1780 C$(N)=M$+";"+DQ$+C$(N)+N$
1784 I=1 '***** NOTE ***** Remove the next line (make it comment) for not simplifying output, but enabling better compatible input (file input is not yet ideal)
1785 J=INSTR(I,C$(N),";"+DQ$+DQ$):IF J<>0 THEN C$(N)=MID$(C$(N),1,J-1)+MID$(C$(N),J+3):I=J:GOTO 1785 '=== delete eventually developed ';""' in definition
1790 GOTO 1510
1810 '
1820 ' Get key name and redefinition
1830 '
1840 IF MID$(C$(N),3,2)="0;" THEN L(N)=2:GOTO 1880